home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr47 / wasm223.zip / CRC.PAS < prev    next >
Pascal/Delphi Source File  |  1993-05-04  |  2KB  |  43 lines

  1. {************************************************************************}
  2. { CRC Generator                                                          }
  3. {                                                                        }
  4. { This routine updates a CRC value by one byte.  The machine code (i.e.  }
  5. { the arguments for Inline) was created from the file CRC_TP.ASM.  To    }
  6. { use this routine, first compile this file and include a "USES CRC;" in }
  7. { the program using crc16.  A routine to generate an xmodem CRC value    }
  8. { for a string of characters could be written as:                        }
  9. {                                                                        }
  10. {    FUNCTION crc_of_block (block: String): Word;                        }
  11. {    VAR                                                                 } 
  12. {      crcval,i: Word;                                                   }
  13. {    BEGIN                                                               }
  14. {      crcval := 0;                                                      }
  15. {      FOR i := 1 TO Length (block) DO                                   }
  16. {        crc16 (crcval, Ord(block[i]));                                  }
  17. {      crc16 (crcval, 0);                                                }
  18. {      crc16 (crcval, 0);                                                }
  19. {      crc_of_block := crcval;                                           }
  20. {    END;                                                                }
  21. {************************************************************************}
  22.  
  23. UNIT CRC;
  24.  
  25. INTERFACE
  26.  
  27. PROCEDURE crc16 (VAR crc: Word; data: Byte);
  28.  
  29. IMPLEMENTATION
  30.  
  31. {$F+}
  32. PROCEDURE crc16 (VAR crc: Word; data: Byte);
  33. BEGIN
  34.   Inline (
  35.     $1E/$8A/$46/$06/$C5/$5E/$08/$8B/$17/$B9/
  36.     $08/$00/$D0/$E0/$D1/$D2/$73/$04/$81/$F2/
  37.     $21/$10/$E2/$F4/$89/$17/$1F
  38.   );
  39. END;
  40. {$F-}
  41.  
  42. END.
  43.